<?php
	// for develpment evirontment only, please use site.js in production environtment
	initLib();
	
	// =================================== include your classes here ===================================
	
	uses("pasta");
	uses("pasta.util.ArrayList");
	uses("pasta.util.EventObj");

	uses("pasta.util.Font");
	uses("pasta.util.MapList");
	uses("pasta.util.Timer");

	uses("pasta.service.Ajax");
	uses("pasta.service.RemoteObject");

	uses("pasta.webgui.Control");
	uses("pasta.webgui.ContainerControl");
	uses("pasta.webgui.Stage");
	uses("pasta.webgui.App");

	uses("pasta.webgui.Button");
	uses("pasta.webgui.CheckBox");
	uses("pasta.webgui.DropDownBox");
	uses("pasta.webgui.Edit");
	uses("pasta.webgui.DatePicker");
	uses("pasta.webgui.ImageButton");
	uses("pasta.webgui.ImagePushButton");
	uses("pasta.webgui.Label");
	uses("pasta.webgui.Memo");
	uses("pasta.webgui.Panel");
	uses("pasta.webgui.Picture");
	uses("pasta.webgui.RadioButton");
	uses("pasta.webgui.Shape");
	uses("pasta.webgui.SimplePageControl");

	// codium classes
	
	uses("codium.CodiumService");
	
	uses("codium.control.MenuButton");
	uses("codium.control.PageControl");
	uses("codium.control.TicketList");
	uses("codium.control.PeopleList");
	uses("codium.control.MessageList");
	uses("codium.control.FileList");
	uses("codium.control.AttachmentList");
	uses("codium.control.IFrame");
	
	uses("codium.panel.NewMessage");
	uses("codium.panel.NewTicket");
	uses("codium.panel.Solution");
	uses("codium.panel.TicketItem");
	uses("codium.panel.NewFile");
	uses("codium.panel.NewPeople");
	
	uses("codium.panel.Login");
	uses("codium.panel.Menu");	
	uses("codium.panel.UserInfo");
	uses("codium.panel.BasicPanel");
	uses("codium.panel.Overview");
	uses("codium.panel.Milestone");
	uses("codium.panel.Ticket");
	uses("codium.panel.File");
	uses("codium.panel.People");
	uses("codium.panel.Setting");
	
	uses("codium.App");

	// ======================================= end class inclusion ======================================
	
	function initLib()
	{
		header('Content-type: text/javascript');
		header('Cache-Control: no-cache');
		
		global $libList;
		$libList = scandir(__DIR__ . "/lib");
		
		echo("var __currFileName = '';\n");
		echo("var __currDirName = '';\n");
		echo("var __currLibDir = '';\n");
	}
	
	function uses($className)
	{
		if ($className == "pasta")
		{
			echo(file_get_contents(__DIR__ . "/lib/pasta.js") . "\n");
		}
		else
		{
			global $libList;
			
			$targetName = str_replace(".", "/", $className);
			
			foreach ($libList as $key => $value)
			{
				if (($value != ".") && ($value != ".."))
				{
					if (file_exists(__DIR__ . "/lib/$value/classes/$targetName.js"))
					{
						echo("__currFileName = 'lib/$value/classes/$targetName.js';\n");
						echo("__currDirName = 'lib/$value/classes';\n");
						echo("__currLibDir = 'lib/$value';\n");
						
						echo(file_get_contents(__DIR__ . "/lib/$value/classes/$targetName.js") . "\n");
					}
				}
			}
		}
	}
?>